// vars/renderTemplate.groovy
import groovy.text.StreamingTemplateEngine

def call(String resourcePath, Map binding) {
    def tpl = libraryResource resourcePath
    return renderTemplateText(tpl, binding)
}

@NonCPS
def renderTemplateText(String templateText, Map binding) {
    def engine = new StreamingTemplateEngine()
    return engine.createTemplate(templateText).make(binding).toString()
}